package com.situ.mall.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.situ.mall.common.entity.Product;
import com.situ.mall.common.vo.EditProductVO;
import com.situ.mall.common.vo.IndexProductVO;
import com.situ.mall.common.vo.ProductVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author kkkkkk
 * @since 2023-09-12
 */
public interface ProductMapper extends BaseMapper<Product> {

    List<ProductVO> list(@Param("name") String name, @Param("status") String status);

    void delete2(String[] split);

    @Select("SELECT product.*,category.parent_id 'topCategory' FROM product INNER JOIN category ON category.id=product.category_id WHERE product.id=#{id}")
    EditProductVO edit(Integer id);

    @Select("select * from product where category_id = #{id} order by price limit 0,1")
    IndexProductVO selectCheap(Integer id);
}
